<?php

class FeedList extends CActiveRecord
{
	private $_feedId = 0;

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{feed_list}}';
	}

	/*
	 * @ 重新relations
	 *   映射用户表
	 */
	public function relations()
	{
		return array(
			'users' => array(self::BELONGS_TO, 'Users', 'user_id'),
			'userprofile' => array(self::BELONGS_TO, 'Profile', 'user_id'),
			'comments' => array(self::HAS_MANY, 'FeedRelation', 'referenced_feed_id','condition'=>"comments.type='comment'"),
		);
	}

	/*
	 * @ 创建成功后
	 */
	public function afterSave()
	{
		parent::afterSave();
		UserFeedIndex::model()->addFeedIndex($this->attributes['event_id'], $this->create_time,$this->type);
		//新增用户事件
		if($this->type != 'comment' && $this->dayevent != '')
			UserEvent::model()->addUserEvent(Yii::app()->user->getId(),$this->dayevent);
	}

	/*
	 * 
	 */
}